<template>
	<view class="detail-page">
		<img :src="url" alt="">
	</view>
</template>

<script>
	import Cookies from 'js-cookie'
	import nodata from '@/components/nodata.vue'
	export default {
		components:{
			nodata
		},
		data() {
			return {
				url:''
			}
		},
		onLoad(obj) {
			this.photo = uni.getStorageSync("photo");
			this.nickName = uni.getStorageSync("nickName");
			this.jobName = uni.getStorageSync("jobName");
			this.mobile = uni.getStorageSync("mobile");
			this.active = Number(obj.active);
			this.select(this.active);
			this.getData();
			this.getData1();
		},
		methods: {
			submit(type){
				uni.showToast({
					title:'您的密码已修改',
					iconfont:'success'
				})
				setTimeout(()=>{
					this.back();
				},500)
			},
			close(item){
				let that = this;
				uni.showModal({
				    title: '提示',
				    content: '请确认是否取消收藏该课程?',
				    success: function (res) {
				        if (res.confirm) {
				        	that.$http.post("/f/collectionCourse?rootCourseId="+item.rootCourseId)
					         .then(function (response) {
						            uni.showToast({
						            	title:'已取消',
						            	icon:'none'
						            })
					                that.getData1();
					         })
					         .catch(function (error) {
					            // handle error
					            console.log(error);
					         })
				            
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
			getData(){
		      let that = this;
		      this.$http.post("/f/pageUserCertificate?pageNo="+this.pageNo1+"&pageSize="+this.pageSize1)
		      .then(function (response) {
		          let list = response.data;
		          if(list.length!=0){
		            list.forEach((item,i)=>{
		              item = Object.assign(item,item.educationModelCertificate,item.educationCourse)
		            })
		          }
		          
		          that.courseList = list;
		          that.start = true;
		      })
		      .catch(function (error) {
		          // handle error
		          console.log(error);
		      })
		    },
		    getData1(){
	          let that = this;
	          this.loading = true;
	          this.$http.post("/f/pageCollectionCourse?pageNo="+this.pageNo2+"&pageSize="+this.pageSize2)
	          .then(function (response) {
	                let list = response.data;
	                if(list.length!=0){
	                    list.forEach((item,i)=>{
	                        item = Object.assign(item,item.educationCourse,item.educationCourse.courseInfo)
	                    })
	                }
	                that.courseList1 = list;
	                that.start1 = true;
	          })
	          .catch(function (error) {
	              // handle error
	              console.log(error);
	          })
	        },
			back(){
				uni.navigateBack({
				    delta: 1
				});
			},
			goPage(url){
				uni.navigateTo({
					url:url
				})
			},
			select(index){
				this.active = index;
				this.list.forEach((item,i)=>{
					if(i==index){
						item.addClass = "active"
					}
					else{
						item.addClass = ""
					}
				})
			}
		}
	}
</script>

<style lang="less">
	.detail-page{
		width:100%;
		height:100%;
		background:#f5f5f5;
	}
</style>
